package com.wangyi.common;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wangyi.bean.Message;

public class HomeListAdapter extends BaseAdapter {
	private final Context context ;
	private final List<Message> messageList;

	public HomeListAdapter(Context context, List<Message> message) {
		super();
		this.context = context;
		this.messageList = message;
	}
	
	@Override
	public int getCount() {
		return messageList.size();
	}

	@Override
	public Object getItem(int position) {
		return messageList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HoldView holdView = null;
		if(convertView==null){
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(com.wangyi.activity.R.layout.home_listadapter, null);
			/**/
			holdView = new HoldView();
			holdView.message = (TextView) convertView.findViewById(com.wangyi.activity.R.id.home_message);
			convertView.setTag(holdView);
		}else{
			holdView = (HoldView) convertView.getTag();
		}
		holdView.message.setText(messageList.get(position).getMessage());
		return convertView;
	}
	
	static class HoldView{
		private TextView message;
		/*
		private TextView nectname;
		private TextView comment;
		private TextView twitter;
		private TextView twitterfrom;
		private ImageView twitterimg;
		private ImageView userPic;
		private Button transpondBtn;
		private Button commentBtn;
		private Button collectBtn;*/
	}
}
